﻿//页面加载
$(document).ready(function () {
    $("#btnSave").bind("click", btnSave_click);
    $("#btnCancel").bind("click", btnCancel_click);

})

function btnSave_click() {

    var v_oldPwd = $("#oldPwd").val();
    if (v_oldPwd == "") {
        alert("请输入原密码");
        return;
    }
    var v_newPwd = $("#newPwd").val();
    if (v_newPwd == "") {
        alert("请输入新密码");
        return;
    }
    var v_newPwd2 = $("#newPwd2").val();
    if (v_newPwd2 == "") {
        alert("请输入确认新密码");
        return;
    }
    if (v_newPwd != v_newPwd2)
    {
        alert("新密码和确认密码不一致");
        return;
    }
    v_userName = $("#UserName").val();

    //异步提交表单,表单中input元素必须设置name 属性
    $.post("/Employee/ChangePassword", { userName: v_userName, oldPwd: v_oldPwd, newPwd: v_newPwd, newPwd2: v_newPwd2 }, function (result) {
        if (result.code == "OK") {
            alert(result.msg);
            window.location.href = "/WelCome/SignOut";
        }
        else {
            alert(result.msg);
        }
    });
}

function btnCancel_click() {
    window.history.go(-1);
}